﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wlmy.Ids4.Common;
using Wlmy.Ids4.Model.Dto.CommonOutput;
using Wlmy.Ids4.Model.Dto.UserClaim;
using Wlmy.Ids4.Model.Model;
using Wlmy.Ids4.Repository;

namespace Wlmy.Ids4.Services
{
    public class UserClaimServices:BaseServices<UserClaim>, IUserClaimServices
    {
        private readonly IUserClaimRepository _userClaimRepository;

        public UserClaimServices(IUserClaimRepository userClaimRepository)
            :base(userClaimRepository)
        {
            _userClaimRepository = userClaimRepository;
        }

        public async Task<PageRequestOutput<GetUserClaimListOutput>> GetClaimListAsync(GetUserClaimListInput input)
        {
            var query = GetALL();
            var count = await query.CountAsync();
            var list = await query.Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize).ToListAsync();
            var dtoList = mapper.Map<List<GetUserClaimListOutput>>(list);
            return new PageRequestOutput<GetUserClaimListOutput>(dtoList, count);
        }
    }
}
